package com.hdu.point_offer;

public class lc136 {

    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }

    class Solution {
        public ListNode deleteNode(ListNode head, int val) {
            ListNode dummy = new ListNode(-1);
            ListNode cur = dummy;
            while (head != null)
            {
                if (head.val == val)
                {
                    while (head != null && head.val == val)
                    {
                        head = head.next;
                    }
                    // head == null || head.val != val
                }
                cur.next = head;
                cur = cur.next;
                if (head != null) head = head.next;
            }
            return dummy.next;
        }
    }
}
